package cn.yunhe.control;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yunhe.entity.Blank;
import cn.yunhe.server.BlankServer;

@WebServlet("/AddBlankServlet")
public class AddBlankServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		String bName = request.getParameter("uName");
		Blank blank = new Blank(); // 新建一个板块对象
		blank.setbName(bName); // 添加板块名称
		BlankServer bServer = new BlankServer();
		boolean flag = bServer.addBlank(blank); // 调用板块增加方法
		if (flag) {
			request.setAttribute("result", "板块添加成功!!");
			request.getRequestDispatcher("addBlank.jsp").forward(request, response);
		}else {
			request.setAttribute("result", "板块添加失败!!");
			request.getRequestDispatcher("addBlank.jsp").forward(request, response);
		}
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(req, resp);
	}
}
